#include<iostream>
#include<string>
#include<map>
using namespace std;
string s;
map<string, int>mp;
int main()
{
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		int j = i;
		int cnt = 0;
		string temp = "";
		if (s[j] == '{') {
			while (s[j] == '{') {
				cnt++;
				j++;
			}
			while (s[j] != '}') {
				temp += s[j];
				j++;
			}
			i = j + cnt;
		}
		else {
			while (s[j] != ',') {
				temp += s[j];
				j++;
			}
			i = j;
		}
		cout << temp << " " << cnt << endl;
	}
	return 0;
}